"""
第一条线性用例模块
测试更改个人信息-进入个人资料更改页面
"""

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
# 进入crm
driver = webdriver.Chrome()
driver.implicitly_wait(30)
driver.maximize_window()
driver.get('http://192.168.1.25/crm')

'''登录'''
# 定位器
username_locator = (By.NAME, 'name')
password_locator = (By.NAME, 'password')
btn_locator = (By.NAME, "submit")

geren_btn_locator = (By.XPATH, '/html/body/div[1]/div/div/div[2]/ul[2]/li[6]/a')
gerenziliao_btn_locator = (By.LINK_TEXT, "个人资料")
# 登录操作
driver.find_element(*username_locator).send_keys("admin")
driver.find_element(*password_locator).send_keys('123456')
driver.find_element(*btn_locator).click()
sleep(2)
# 点击进入个人资料
driver.find_element(*geren_btn_locator).click()
driver.find_element(*gerenziliao_btn_locator).click()
# 断言
dl_url = driver.current_url
if dl_url == 'http://192.168.1.25/crm/index.php?m=user&a=edit':
    pass
else:
    raise AssertionError('测试不通过')
'''清理环境'''
sleep(2)
driver.quit()